<%= render 'nav' %>

<table class="table table-striped table-bordered">
  <thead>
  <tr>
    <th>编号</th>
    <th>客户</th>
    <th>产品</th>
    <th>数量</th>
    <th>销售时间</th>
    <th>到期时间</th>
    <th>获得奖励</th>
  </tr>
  </thead>

  <tbody>
  <% @sales.each do |sale| %>
      <tr>
        <td><%= sale.id %></td>
        <td><%= link_to sale.customer.name, customer_path(sale.customer) %></td>
        <td><%= link_to sale.product.name, product_path(sale.product) %></td>
        <td><%= sale.product_number %></td>
        <td><%= sale.sold_at.strftime('%F') %></td>
        <td><%= sale.product_expired_at.try(:strftime, '%F') %></td>
        <td><%= sale.sales_reward %></td>
      </tr>
  <% end %>
  </tbody>
</table>

<%= render partial: 'shared/paginate', locals: {collection: @sales} %>
